package br.com.sistema.models;

import java.util.Calendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

@Entity
@Table(name="cep")
public class Cep {
	
	@Id
	@Column(name="cepid")
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer cepid;

	@Column(name="ceplogradouro")
	private String ceplogradouro;
	
	@Column(name="cepbairro")
	private String cepbairro;
	
	@Column(name="cepcodigo", nullable=false)
	private String cepcodigo;
	
	@Column(name="xdatai", nullable=false)
	@Temporal(TemporalType.TIMESTAMP)
	private Calendar xdatai;
	
	@Column(name="xdatau", nullable=false)
	@Temporal(TemporalType.TIMESTAMP)
	private Calendar xdatau;
	
	@Column(name="xusuario", nullable=false)
	private String xusuario;

	@Version
	@Column(name="xversao")
	private Integer xversao;
	
	@PrePersist
	public void prePersist(){
		this.xdatai = Calendar.getInstance();
		this.xdatau = Calendar.getInstance();
	}
	
	@PreUpdate
	public void preUpdate(){
		this.xdatau = Calendar.getInstance();
	}

	public Integer getCepid() {
		return cepid;
	}

	public void setCepid(Integer cepid) {
		this.cepid = cepid;
	}

	public String getCeplogradouro() {
		return ceplogradouro;
	}

	public void setCeplogradouro(String ceplogradouro) {
		this.ceplogradouro = ceplogradouro;
	}

	public String getCepbairro() {
		return cepbairro;
	}

	public void setCepbairro(String cepbairro) {
		this.cepbairro = cepbairro;
	}

	public String getCepcodigo() {
		return cepcodigo;
	}

	public void setCepcodigo(String cepcodigo) {
		this.cepcodigo = cepcodigo;
	}

	public Calendar getXdatai() {
		return xdatai;
	}

	public void setXdatai(Calendar xdatai) {
		this.xdatai = xdatai;
	}

	public Calendar getXdatau() {
		return xdatau;
	}

	public void setXdatau(Calendar xdatau) {
		this.xdatau = xdatau;
	}

	public String getXusuario() {
		return xusuario;
	}

	public void setXusuario(String xusuario) {
		this.xusuario = xusuario;
	}

	public Integer getXversao() {
		return xversao;
	}

	public void setXversao(Integer xversao) {
		this.xversao = xversao;
	}

}
